package com.security.web.controller;


import com.security.web.domain.JwtUser;
import com.security.web.entity.SysUser;
import com.security.web.service.SysUserService;
import com.security.web.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("")
public class LoginController {

    @Autowired
    SysUserService userService;

    @PostMapping("/register")
    @ResponseBody
    public AjaxResult registerUser(SysUser user) {
        return userService.addUser(user);
    }

    @RequestMapping("/login")
    public String login(){
        return "login";
    }

    @PostMapping("/login")
    @ResponseBody
    public AjaxResult login(SysUser user, HttpServletRequest request) {
        return userService.login(user, request);
    }
}
